[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 spawnlp()               Execute Program Using Argument List and PATH

 #include <process.h>

 int        spawnlp(modeflag,pathname,arg0,arg1,...,argn,NULL)
 int        modeflag;                    Execution mode for parent process
 char       *pathname;                   Path name of file to be executed
 char       *arg0,*arg1,...,*argn;       List of pointers to argument

    spawnlp() operates exactly like spawnl(), with one exception:  If
    'pathname' is not found as described in spawnl(), then spawnlp() uses
    the current directory, then the DOS PATH to continue the search for
    the path name.  Otherwise, the two functions are identical; see
    spawnl() for a complete description.

   Portability:     MS-DOS only.

   -------------------------------- Example ---------------------------------

    The following statements transfer execution to the child process
    "child.exe" and pass it the three arguments "child", "arg1", and
    "arg2".  "child.exe" will be found in the current directory or any
    PATH directory.  The exit status of the child is printed upon return.

           #include <process.h>    /* for 'spawnlp' and 'P_WAIT' */
           #include <stdio.h>      /* for 'printf' and 'NULL' */
           #include <errno.h>      /* for 'errno', 'ENOENT' and 'ENOMEM' */

           main()
           {
               int result;

               result = spawnlp(P_WAIT,"child.exe","child",
                                "arg1","arg2",NULL);
              if (result != -1)
                  printf("exit status of child.exe = %d\n", result);
              else {
                  if (errno == ENOENT) {
                      printf("child.exe not found in current directory,\n");
                      printf("  or in any PATH directory.\n");
                  }
                  else if (errno == ENOMEM)
                      printf("not enough memory to execute child.exe\n");
                  else
                      printf("error #%d trying to spawn child.exe\n", errno);
               }
           }


See Also: spawnl() spawn...() exec...()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson